// StamdataDaoForm.cpp : implementation file
//

#include "stdafx.h"
#include "EBASApp.h"
#include "StamdataDaoForm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStamdataDaoForm

IMPLEMENT_DYNCREATE(CStamdataDaoForm, CDaoRecordView)

CStamdataDaoForm::CStamdataDaoForm()
	: CDaoRecordView(CStamdataDaoForm::IDD)
{
	//{{AFX_DATA_INIT(CStamdataDaoForm)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
}

CStamdataDaoForm::~CStamdataDaoForm()
{
}

void CStamdataDaoForm::DoDataExchange(CDataExchange* pDX)
{
	CDaoRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStamdataDaoForm)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStamdataDaoForm, CDaoRecordView)
	//{{AFX_MSG_MAP(CStamdataDaoForm)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStamdataDaoForm diagnostics

#ifdef _DEBUG
void CStamdataDaoForm::AssertValid() const
{
	CDaoRecordView::AssertValid();
}

void CStamdataDaoForm::Dump(CDumpContext& dc) const
{
	CDaoRecordView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CStamdataDaoForm message handlers

CDaoRecordset* CStamdataDaoForm::OnGetRecordset()
{
	if (m_pSet != NULL)
		return m_pSet;

	m_pSet = new CStudentDao(NULL);
	m_pSet->Open();

	return m_pSet;
}

CStudentDao* CStamdataDaoForm::GetRecordset()
{
	CStudentDao* pData = (CStudentDao*) OnGetRecordset();
	ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(CStudentDao)));
	return pData;
}

void CStamdataDaoForm::OnInitialUpdate()
{
	BeginWaitCursor();
	GetRecordset();
	CDaoRecordView::OnInitialUpdate();
	if (m_pSet->IsOpen())
	{
		CString strTitle = m_pSet->m_pDatabase->GetName();
		CString strTable = m_pSet->GetName();
		if (!strTable.IsEmpty())
			strTitle += _T(":") + strTable;
		GetDocument()->SetTitle(strTitle);
	}
	EndWaitCursor();
}
